import React, { memo, useEffect } from "react";
import { renderRoutes } from "react-router-config";
import { withRouter } from "react-router-dom";


export default memo(
  withRouter(function Main(props) {
    const { history, location, route } = props;
    const { redirect, children } = route;
    const { pathname } = location;
     console.log(route, "props.route", location);
    useEffect(() => {
      if (pathname === "/") history.push(redirect);
    }, [history, pathname, redirect]);
    return (<div>{renderRoutes(children)}</div>);
  })
);